﻿
namespace WPF.TestEditor.Common
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using ICSharpCode.AvalonEdit.CodeCompletion;
    using System.Windows.Media;
    using ICSharpCode.AvalonEdit.Editing;
    using ICSharpCode.AvalonEdit.Document;

    public class TextEditorComletitionData : ICompletionData
    {
        public TextEditorComletitionData(string text, string description=null, int priority = 0,ImageSource image=null)
        {
            this.Text = text;
            this.Description = string.IsNullOrEmpty(description) ? "Description for " + this.Text : description;
            this.Priority = priority;
            this.Image = image;
        }
        public ImageSource Image { get; set; }
        public string Text { get; set; }

        // Use this property if you want to show a fancy UIElement in the drop down list.
        public object Content
        {
            get { return this.Text; }
        }
        public object Description { get; set; }
        public double Priority { get; set; }

        public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs)
        {
            textArea.Document.Replace(completionSegment, this.Text);
        }
    }
}
